package com.chushouya.controller.manager.api;

import com.chushouya.common.constant.ServiceType;
import com.chushouya.manager.dto.api.bonus.UserExchangeDTO;
import com.chushouya.manager.service.api.ReceiveBonusService;
import com.general.framework.core.schema.Response;
import com.chushouya.manager.dto.admin.bonus.CanUseBonusQuery;
import com.chushouya.manager.dto.api.bonus.CanUserBonusDTO;
import com.chushouya.manager.service.api.UserBonusApiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping(ServiceType.API + "/userBonus")
@Api(tags = ServiceType.API + "用户红包接口")
public class BonusApiController {

    @Resource
    private UserBonusApiService userBonusService;

    @Resource
    private ReceiveBonusService receiveBonusService;

    @GetMapping("/canUseBonusList")
    @ApiOperation("获取用户可用活动红包列表")
    public Response<List<CanUserBonusDTO>> canUseBonusList(CanUseBonusQuery query) {
        return Response.success(userBonusService.canUseBonusQuery(query));
    }

//    @ApiOperation("获取叠加红包列表")
//    @GetMapping("/overlayCouponList")
//    public Response<List<UserBonusDTO>> overlayCouponList(CanUseBonusQuery query) {
//        return Response.success(userBonusService.overlayCouponList(query));
//    }

//    @GetMapping("/bonusList")
//    @ApiOperation("获取活动红包列表")
//    public Response<List<UserBonusDTO>> bonusList(BonusQuery query) {
//        return Response.success(userBonusService.userBonusList(query));
//    }

    @ApiOperation("使用券码兑换红包")
    @PostMapping("/exchange")
    public Response exchange(@RequestBody @Validated UserExchangeDTO dto) {
        receiveBonusService.userExchangeBonus(dto);
        return Response.success();
    }

}
